package com.example.yiqiuser.controller;


import com.example.yiqiuser.entity.News;
import com.example.yiqiuser.service.NewsService;
import com.example.yiqiuser.util.Page;
import com.example.yiqiuser.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author: Jyc
 * @classname: NewsController
 * @date: 2023/3/31
 * @time: 15:10
 * @description:
 */
@RestController
@RequestMapping("news")
public class NewsController extends BaseController {
    @Resource
    private NewsService newsService;

    @PostMapping("queryByPage")
    public Result queryByPage(@RequestBody Page<News> page){
        return success(newsService.queryParams(page));
    }

    @PostMapping("queryById")
    public Result queryById(int id){
        return success(newsService.queryById(id));
    }
    @DeleteMapping("deleteById")
    public Result deleteById(int id){
        return success(newsService.delete(id));
    }

    @PostMapping("adds")
    public Result adds(@RequestBody News news){
        return success(newsService.adds(news));
    }

    @PostMapping("update")
    public Result update(@RequestBody News news){
        return success(newsService.update(news));
    }
}
